/*
  Diamond Girl - Game where player collects diamonds.
  Copyright (C) 2005-2014  Joni Yrjänä <joniyrjana@gmail.com>
  
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.
  
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
  
  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


  Complete license can be found in the LICENSE file.
*/

#include "widget.h"
#include "font.h"
#include "gfx.h"

struct widget * widget_new_game_help_window(void)
{
  const char * help[] =
    {
      "Controls:",
      "",
      " F1",          " - pause and display this help",
      " F2",          " - pause and display legend",
      " F10",         " - toggle windowed/fullscreen",
      " ALT+ENTER",   " - toggle windowed/fullscreen",
      " ESC",         " - suicide",
      " PAUSE",       " - pause game,",
      "",             "   press PAUSE again to resume",
      " CURSOR keys", " - move",
      " SHIFT+CURSOR keys", " - don't move, manipulate only",
      "", "",
      "If you press ESC after dying, you will return to the main menu.", "",
      NULL
    };
  int i, y, width, controlwidth, height;
  struct widget * help_window;

  i = 0;
  width = 0;
  controlwidth = 0;
  while(help[i] != NULL)
    {
      int w;

      w = font_width(help[i]) + font_width(help[i + 1]);
      if(w > width)
        width = w;
      if(strlen(help[i + 1]) > 0)
        controlwidth = width;
      i += 2;
    }

  width += 30;
  height = (i / 2 + 2) * font_height();

  help_window = widget_new_frame(widget_root(), 0, 0, width, height);
  widget_center(help_window);
        
  y = font_height();
  i = 0;
  while(help[i] != NULL)
    {
      widget_new_text(help_window, 15,               y, help[i    ]);
      widget_new_text(help_window, controlwidth / 2, y, help[i + 1]);

      y += font_height();
      i += 2;
    }

  return help_window;
}
